package com.lfl.action;

import com.lfl.dao.EmplyeeDao;
import com.lfl.dao.impl.EmplyeeDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: JavaEE-EFD
 * @description: Emp业务类
 * @author: fengjd
 * @create: 2022-07-27 17:09
 **/
public class AddEmpAction extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            synchronized (this) {
                String name = request.getParameter("name");
                EmplyeeDao ed = new EmplyeeDaoImpl();
                ed.add(name);
                response.sendRedirect("indexPage.action");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
